package com.globalwave.product.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;

import com.globalwave.base.BaseEntity;

@Entity
@Table(name = "PRODUCT_PRODUCT")
public class Product extends BaseEntity implements Serializable  {
	

	// ------------------ Lock Status -------------------------
	//库存锁定标志
    public static final Short INVENTORY_LOCK_SALABLE = 1; //可销售
    public static final Short INVENTORY_LOCK_UNSALABLE = 0; //不可销售
	
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="increment")
    @GenericGenerator(name="PRODUCT_PRODUCT_ID_SEQ", strategy = "increment")
	private Long product_id ;
	private Long catalog_id ;
	private Long main_photo_id ; 
	private Long template_id ;
	
	 private String   region_code         ;
	 private String   warehouse_code      ;
	 private Long     item_number         ;
	 private String   item_sku            ;
	 private Long     stock_item_number   ;
	 private String   short_desc          ;
	 private String   full_desc           ;
	 private String   short_desc_en       ;
	 private String   full_desc_en        ;
	 private Double   pre_original_price  ;
	 private Double   pre_discount_price  ;
	 private Double   pre_price1          ;
	 private Double   pre_price2          ;
	 private Double   pre_nation_tax      ;
	 private Double   pre_location_tax    ;
	 private String   pre_currency_code   ;
	 private Short    pre_salable_status  ;
	 private Long     until_date_time     ;
	 private Double   post_original_price ;
	 private Double   post_discount_price ;
	 private Double   post_price1         ;
	 private Double   post_price2         ;
	 private Double   post_nation_tax     ;
	 private Double   post_location_tax   ;
	 private String   post_currency_code  ;
	 private Short    post_salable_status ;
	 private String   unit_code           ;
	 private String   return_type         ;
	 private Short    status_             ;
	 private Short    keying_flag         ;
	 private Short    stock_control_flag  ;
	 private Short    count_flag          ;
	 private Short    item_source_type    ;
	 private Short    promotion_flag      ;
	 private String   discount_type       ;
	 private Short    package_flag        ;
	 private Short    item_status_table_flag ;
	 private Short    biz_flag               ;
	 private Short    advanced_flag          ;
	 private String   percentage_list     ;
	 
	 @Transient
	 private Set<Integer>   percentages     ;
	 
	 
	public Long getProduct_id() {
		return product_id;
	}
	public void setProduct_id(Long product_id) {
		this.product_id = product_id;
	}
	public Long getCatalog_id() {
		return catalog_id;
	}
	public void setCatalog_id(Long catalog_id) {
		this.catalog_id = catalog_id;
	}
	public Long getMain_photo_id() {
		return main_photo_id;
	}
	public void setMain_photo_id(Long main_photo_id) {
		this.main_photo_id = main_photo_id;
	}
	public Long getTemplate_id() {
		return template_id;
	}
	public void setTemplate_id(Long template_id) {
		this.template_id = template_id;
	}
	public String getRegion_code() {
		return region_code;
	}
	public void setRegion_code(String region_code) {
		this.region_code = region_code;
	}
	public String getWarehouse_code() {
		return warehouse_code;
	}
	public void setWarehouse_code(String warehouse_code) {
		this.warehouse_code = warehouse_code;
	}
	public Long getItem_number() {
		return item_number;
	}
	public void setItem_number(Long item_number) {
		this.item_number = item_number;
	}
	public String getItem_sku() {
		return item_sku;
	}
	public void setItem_sku(String item_sku) {
		this.item_sku = item_sku;
	}
	public Long getStock_item_number() {
		return stock_item_number;
	}
	public void setStock_item_number(Long stock_item_number) {
		this.stock_item_number = stock_item_number;
	}
	public String getShort_desc() {
		return short_desc;
	}
	public void setShort_desc(String short_desc) {
		this.short_desc = short_desc;
	}
	public String getFull_desc() {
		return full_desc;
	}
	public void setFull_desc(String full_desc) {
		this.full_desc = full_desc;
	}
	public String getShort_desc_en() {
		return short_desc_en;
	}
	public void setShort_desc_en(String short_desc_en) {
		this.short_desc_en = short_desc_en;
	}
	public String getFull_desc_en() {
		return full_desc_en;
	}
	public void setFull_desc_en(String full_desc_en) {
		this.full_desc_en = full_desc_en;
	}
	public Double getPre_original_price() {
		return pre_original_price;
	}
	public void setPre_original_price(Double pre_original_price) {
		this.pre_original_price = pre_original_price;
	}
	public Double getPre_discount_price() {
		return pre_discount_price;
	}
	public void setPre_discount_price(Double pre_discount_price) {
		this.pre_discount_price = pre_discount_price;
	}
	public Double getPre_price1() {
		return pre_price1;
	}
	public void setPre_price1(Double pre_price1) {
		this.pre_price1 = pre_price1;
	}
	public Double getPre_price2() {
		return pre_price2;
	}
	public void setPre_price2(Double pre_price2) {
		this.pre_price2 = pre_price2;
	}
	public Double getPre_nation_tax() {
		return pre_nation_tax;
	}
	public void setPre_nation_tax(Double pre_nation_tax) {
		this.pre_nation_tax = pre_nation_tax;
	}
	public Double getPre_location_tax() {
		return pre_location_tax;
	}
	public void setPre_location_tax(Double pre_location_tax) {
		this.pre_location_tax = pre_location_tax;
	}
	public String getPre_currency_code() {
		return pre_currency_code;
	}
	public void setPre_currency_code(String pre_currency_code) {
		this.pre_currency_code = pre_currency_code;
	}
	public Short getPre_salable_status() {
		return pre_salable_status;
	}
	public void setPre_salable_status(Short pre_salable_status) {
		this.pre_salable_status = pre_salable_status;
	}
	public Long getUntil_date_time() {
		return until_date_time;
	}
	public void setUntil_date_time(Long until_date_time) {
		this.until_date_time = until_date_time;
	}
	public Double getPost_original_price() {
		return post_original_price;
	}
	public void setPost_original_price(Double post_original_price) {
		this.post_original_price = post_original_price;
	}
	public Double getPost_discount_price() {
		return post_discount_price;
	}
	public void setPost_discount_price(Double post_discount_price) {
		this.post_discount_price = post_discount_price;
	}
	public Double getPost_price1() {
		return post_price1;
	}
	public void setPost_price1(Double post_price1) {
		this.post_price1 = post_price1;
	}
	public Double getPost_price2() {
		return post_price2;
	}
	public void setPost_price2(Double post_price2) {
		this.post_price2 = post_price2;
	}
	public Double getPost_nation_tax() {
		return post_nation_tax;
	}
	public void setPost_nation_tax(Double post_nation_tax) {
		this.post_nation_tax = post_nation_tax;
	}
	public Double getPost_location_tax() {
		return post_location_tax;
	}
	public void setPost_location_tax(Double post_location_tax) {
		this.post_location_tax = post_location_tax;
	}
	public String getPost_currency_code() {
		return post_currency_code;
	}
	public void setPost_currency_code(String post_currency_code) {
		this.post_currency_code = post_currency_code;
	}
	public Short getPost_salable_status() {
		return post_salable_status;
	}
	public void setPost_salable_status(Short post_salable_status) {
		this.post_salable_status = post_salable_status;
	}
	public String getUnit_code() {
		return unit_code;
	}
	public void setUnit_code(String unit_code) {
		this.unit_code = unit_code;
	}
	public String getReturn_type() {
		return return_type;
	}
	public void setReturn_type(String return_type) {
		this.return_type = return_type;
	}
	public Short getStatus_() {
		return status_;
	}
	public void setStatus_(Short status_) {
		this.status_ = status_;
	}
	public Short getKeying_flag() {
		return keying_flag;
	}
	public void setKeying_flag(Short keying_flag) {
		this.keying_flag = keying_flag;
	}
	public Short getStock_control_flag() {
		return stock_control_flag;
	}
	public void setStock_control_flag(Short stock_control_flag) {
		this.stock_control_flag = stock_control_flag;
	}
	public Short getCount_flag() {
		return count_flag;
	}
	public void setCount_flag(Short count_flag) {
		this.count_flag = count_flag;
	}
	public Short getItem_source_type() {
		return item_source_type;
	}
	public void setItem_source_type(Short item_source_type) {
		this.item_source_type = item_source_type;
	}
	public Short getPromotion_flag() {
		return promotion_flag;
	}
	public void setPromotion_flag(Short promotion_flag) {
		this.promotion_flag = promotion_flag;
	}
	public String getDiscount_type() {
		return discount_type;
	}
	public void setDiscount_type(String discount_type) {
		this.discount_type = discount_type;
	}
	public Short getPackage_flag() {
		return package_flag;
	}
	public void setPackage_flag(Short package_flag) {
		this.package_flag = package_flag;
	}
	public Short getItem_status_table_flag() {
		return item_status_table_flag;
	}
	public void setItem_status_table_flag(Short item_status_table_flag) {
		this.item_status_table_flag = item_status_table_flag;
	}
	public Short getBiz_flag() {
		return biz_flag;
	}
	public void setBiz_flag(Short biz_flag) {
		this.biz_flag = biz_flag;
	}
	public Short getAdvanced_flag() {
		return advanced_flag;
	}
	public void setAdvanced_flag(Short advanced_flag) {
		this.advanced_flag = advanced_flag;
	}
	public String getPercentage_list() {
		return percentage_list;
	}
	public void setPercentage_list(String percentage_list) {
		this.percentage_list = percentage_list;
		
		if (percentage_list != null) {
			percentages = new HashSet<Integer>() ;
			
			String[] ps = percentage_list.split("/") ;
			for (String p:ps) {
				percentages.add(Integer.valueOf(p)) ;
			}
		}
	}
	
	public boolean contains(Integer percentage) {
		if (percentages == null) {
			if (percentage == 100) {
				return true ;
			} else {
			    return false ;
			}
		}
		
		return percentages.contains(percentage) ;
	}
		
}
